﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using WebLogic.Model.Page;
@{
    Layout = null;
    var section = ViewData["model"] as SectionModel;
    if (section == null)
    {
        section = new SectionModel();
    }
}
<!DOCTYPE html>
<html>
<head>
    @Html.Partial(IncludePath("header"))
    <style type="text/css">
        .lb {
            margin-top: 20px;
            margin-bottom: 20px;
            font-weight: bold;
            font-size: 16px;
        }
    </style>
</head>
<body>
    @Html.Partial(IncludePath("body_top"))

    <div class="container-fluid" style="margin-top: 10px; margin-bottom: 100px;">
        <div class="row">
            <div class="col-md-12">
                <form id="fm">
                    <table class="table table-hover">
                        <tbody>
                            <tr>
                                <td colspan="2">
                                    <div class="right">
                                        <button class="btn btn-primary btn-sm" type="submit">保存</button>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="active">标识</td>
                                <td style="width:80%">
                                    <input type="hidden" name="id" value="@(section.SectionID)" />
                                    <input type="text" class="form-control" name="section_name" value="@(section.SectionName)" />
                                </td>
                            </tr>
                            <tr>
                                <td class="active">标题</td>
                                <td>
                                    <input type="text" class="form-control" name="section_title" value="@(section.SectionTitle)" />
                                </td>
                            </tr>
                            <tr>
                                <td class="active">描述</td>
                                <td>
                                    <input type="text" class="form-control" name="section_description" value="@(section.SectionDescription)" />
                                </td>
                            </tr>
                            <tr>
                                <td class="active">类型</td>
                                <td>
                                    <select class="form-control" name="section_type" data-value="@(section.SectionType)">
                                        <option value="page">页面</option>
                                        <option value="news">新闻</option>
                                        <option value="section">内容块</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="active">关联</td>
                                <td>
                                    <input type="text" class="form-control" name="rel_group" value="@(section.RelGroup)" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="box">
                        @{
                            ViewData["edit_html"] = section.SectionContent;
                        }
                        @Html.Partial(IncludePath("html_editor"))

                        <input type="hidden" name="section_content" />
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        //setWidth(800);
        $(function () {

            var form = $('#fm');
            form.submit(function () {

                $("input[name='section_content']").val(getContent());

                var data = $(this).serializeArray();

                postJson("/admin/section/UpdateOrSaveSectionAction/", data, function (res) {
                    if (res.success) {
                        reload_parent();
                    }
                    else {
                        alert(res.msg);
                    }
                });

                return false;
            });

        });
    </script>
    @Html.Partial(IncludePath("body_bottom"))
</body>
</html>
